﻿@page "/"

@inject MessageService MessageService

<Button class="RootButton" Size="Size.ExtraSmall"
        Color="Color.Secondary" Icon="fas fa-plus"
        Text="添加根目录"
        OnClick="() => Task.Run(() => AddRootDirFlag = true)">
</Button>


<Tree Items="TreeItems"
      ShowIcon="true"
      OnTreeItemClick="OnTreeItemClick"
@onmousedown="OnMouseDown"
@onmouseup="OnMouseUp">
</Tree>

@*添加目录/链接的抽屉*@
<Drawer Placement="Placement.Right"
        IsOpen="@DrawComponent.DrawOpenControl"
        IsBackdrop="true"
        OnClickBackdrop="OnCloseDraw">
    <Menu Items="@DrawComponent.DrawMenuItems" DisableNavigation="true" OnClick="@OnClickMenu"></Menu>

    <div class="d-flex justify-content-center align-items-center flex-column" style="height: 290px;margin-left:10px">
        <div class="row g-3">
            <div class="col-12">
                <BootstrapInputGroupLabel DisplayText="当前文件夹/链接名"></BootstrapInputGroupLabel>
                <BootstrapInput TValue="string" IsDisabled="@DrawComponent.DrawFormAbleControl.CurrentDic" @bind-Value="@DrawComponent.DrawFormData.CurrentDic" />
            </div>
            <div class="col-12">
                <BootstrapInputGroupLabel DisplayText="创建文件夹/链接？"></BootstrapInputGroupLabel>
                <Select IsDisabled="@DrawComponent.DrawFormAbleControl.Select" Items="@DrawComponent.DrawSelectItems" @bind-Value="@DrawComponent.SelectedValue"></Select>
            </div>
            <div class="col-12">
                <BootstrapInputGroupLabel DisplayText="文件夹名/链接"></BootstrapInputGroupLabel>
                <BootstrapInput IsDisabled="@DrawComponent.DrawFormAbleControl.Name" TValue="string" @bind-Value="@DrawComponent.DrawFormData.Name" />
            </div>
            <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
                <Button IsDisabled="@DrawComponent.DrawFormAbleControl.Button"
                        IsOutline="true"
                        Color="Color.Info"
                        OnClick="Submit">
                    @DrawComponent.DrawFormAbleControl.ButtonText
                </Button>
            </div>

            <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
                <PopConfirmButton Placement="Placement.Bottom"
                                  Color="Color.Danger"
                                  ConfirmButtonColor="Color.Danger"
                                  ConfirmIcon="fa-solid fa-triangle-exclamation text-danger"
                                  Text="删除"
                                  Content="确定删除数据吗？"
                                  OnConfirm="DeleteConfirm"
                                  OnClose='() => ShowMessageInfo("取消删除", 2)' />
            </div>
        </div>

    </div>
</Drawer>

@*添加根目录抽屉*@
<Drawer Placement="Placement.Right"
        IsOpen="@AddRootDirFlag"
        IsBackdrop="true"
        OnClickBackdrop="() =>  Task.Run(() => AddRootDirFlag = false) ">

    <div class="col-12">
        <BootstrapInputGroupLabel DisplayText="文件夹名"></BootstrapInputGroupLabel>
        <BootstrapInput TValue="string"
        @bind-Value="@AddRootDirName" />
    </div>

    <Button Size="Size.Small"
            Color="Color.Primary"
            style="margin-left: 45%;margin-top:20px"
            Text="添加"
            OnClick="AddRootDir">
    </Button>
</Drawer>


<style>
    .deleteButton {
        margin-left: 60%;
    }

    .RootButton {
        margin-left: 80%;
    }
</style>
